﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using SynoManager.GUI;
using SynoManager.AudioStation.Gui;

namespace SynoManager.AudioStation
{
    [ServiceDependency(typeof(AudioStationService))]
    public class AudioStationGuiPlugin : IGuiPlugin
    {
        private IHost host;
        private AudioStationService service;

        public void InitializeHost(IHost host)
        {
            this.host = host;
        }

        public void Initialize(SynoDevice device)
        {
            service = device.FindService<AudioStationService>();
            Debug.Assert(Service != null, "AudioStationService could not be found");
            service.Plugin = this;
        }

        public void PopulatePreferencesForm(TreeViewEx treeView)
        {
            
        }

        private AudioStationTab tab;
        public Control MainControl
        {
            get
            {
                return Tab;
            }
        }

        public AudioStationTab Tab
        {
            get
            {
                if (!service.Device.IsAdmin)
                    return null;

                if (tab == null)
                {
                    tab = new AudioStationTab(this);
                    updateToolStrip();
                }
                return tab;
            }
        }

        private void updateToolStrip()
        {
            
        }

        private bool tabActive;
        public bool TabActive
        {
            set
            {
                tabActive = value;
                updateToolStrip();
            }
            get
            {
                return tabActive;
            }
        }

        /// <summary>
        /// Gets the priority the tabcontrol order
        /// </summary>
        public int TabPriority
        {
            get { return 500; }
        }

        public AudioStationService Service
        {
            get { return service; }
        }

        #region IGuiPlugin Members


        public void OnConnectionStateChange(bool isConnected, bool wasConnected)
        {
            
        }

        #endregion
    }
}
